#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 110;
int n, m;
int a[N], b[N], e_cnt, heads[N];
double f[N][N], val[N];

struct Edge {
  int v, nxt;
} e[N << 1];

inline void add(int u, int v) { e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt; }

void dfs(int x, int fa) {
  f[x][0] = 0;
  for (int i = heads[x]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa) continue;
    dfs(v, x);
    for (int j = n - m - 1; j; --j) {
      for (int k = j; ~k; --k) {
        f[x][j] = std::max(f[x][j], f[x][j - k] + f[v][k]);
      }
    }
  }
  for (int i = n - m; i; --i) {
    f[x][i] = f[x][i - 1] + val[x];
  }
}

inline bool check(double x) {
  for (int i = 0; i <= n; ++i) {
    val[i] = 1.0 * a[i] - 1.0 * b[i] * x;
    for (int j = 0; j <= n - m; ++j) {
      f[i][j] = -1e6;
    }
  }
  dfs(1, 0);
  for (int i = 1; i <= n; ++i) {
    if (f[i][n - m] > -1e-4) return true;
  }
  return false;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("01ScorePlanning.in", "r", stdin);
  freopen("01ScorePlanning.out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &b[i]);
  }
  int u, v;
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  double l = 0.0, r = 1e6, mid;
  while (r - l > 1e-4) {
    mid = (l + r) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.1lf", l);
  return 0;
}